Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ANR caused by Duck Player #5169

Merged
merged 1 commit into from
Oct 23, 2024
Merged

Conversation

CrisBarreiro
Copy link
Contributor

@CrisBarreiro CrisBarreiro commented Oct 22, 2024

Task/Issue URL: https://app.asana.com/0/1202552961248957/1208580918293550/f

Description

  • Remove unnecessary async/await
  • Improve caching strategy by migrating Flows to StateFlows and using .value instead of .first(). Since .value is a sync operation, this also allowed to get rid of quite a few suspend functions
  • Remove manual caching from DuckPlayerFeatureRepository, as it's no longer needed and we can rely on StateFlows instead

Steps to test this PR

Feature 1

  • Smoke test Duck Player

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @CrisBarreiro and the rest of your teammates on Graphite Graphite

@CrisBarreiro CrisBarreiro force-pushed the fix/cris/duck-player/anr-2 branch 2 times, most recently from 89679f7 to e71ec4d Compare October 22, 2024 08:02
val willNavigateToDuckPlayerDeferred = scope.async(dispatcherProvider.io()) { duckPlayer.willNavigateToDuckPlayer(uri) }

val willNavigateToDuckPlayer = runBlocking(dispatcherProvider.io()) { willNavigateToDuckPlayerDeferred.await() }
val willNavigateToDuckPlayer = runBlocking(dispatcherProvider.io()) { duckPlayer.willNavigateToDuckPlayer(uri) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -371,6 +373,7 @@ class RealDuckPlayer @Inject constructor(
}

private suspend fun doesYoutubeUrlComeFromDuckPlayer(url: Uri, request: WebResourceRequest? = null): Boolean {
val start = SystemClock.elapsedRealtime()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor

@joshliebe joshliebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works as expected! ✅
Just the one comment: #5169 (comment)

@CrisBarreiro CrisBarreiro merged commit 9a36583 into develop Oct 23, 2024
6 checks passed
@CrisBarreiro CrisBarreiro deleted the fix/cris/duck-player/anr-2 branch October 23, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants